import Api from '@/service/api/api';
import { getServiceBaseURL } from '@/utils/service';
import { chatRequest, request, statusRequest } from '../request';

const isHttpProxy = import.meta.env.DEV && import.meta.env.VITE_HTTP_PROXY === 'Y';
const { baseURL, otherBaseURL } = getServiceBaseURL(import.meta.env, isHttpProxy);

/**
 * 标书历史记录
 *
 * @param params
 */
export function historyWriteListAction(params: any) {
  return request<any>({
    url: Api.HistoryWrite,
    method: 'get',
    params
  });
}

/**
 * 查询标书详情
 *
 * @param params
 */
export function taskInfoById(params: any) {
  return request<any>({
    url: Api.SelectById,
    method: 'get',
    params
  });
}

/**
 * 新增标书
 *
 * @param params
 */
export function insertWriteAction(params: any) {
  return request<any>({
    url: Api.InsertWrite,
    method: 'post',
    data: params
  });
}

/**
 * 标书内容转Doc
 *
 * @param params
 */
export function htmlToDocAction(params: any) {
  return request<any>({
    url: Api.HtmlToDoc,
    method: 'post',
    data: params
  });
}

/**
 * 获取租户下的所有知识库
 *
 * @param params
 */
export function getKnowledgeListAction(params: any) {
  return request<any>({
    url: Api.SelectKnowledge,
    method: 'get',
    params
  });
}

/**
 * 更新标书
 *
 * @param params
 */
export function updateWriteAction(params: any) {
  return request<any>({
    url: Api.UpdateWrite,
    method: 'post',
    data: params
  });
}

/**
 * 通用文件上传
 *
 * @param params
 */
export function uploadFileAction(params: any) {
  return request<any>({
    url: Api.UploadFile,
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data: params
  });
}

/**
 * 生成目录
 *
 * @param params
 */
export function simpleGenerateAction(params: any) {
  return statusRequest<any>({
    url: Api.SimpleGenerate,
    method: 'post',
    data: params
  });
}

/**
 * 扣减次数
 *
 * @param params
 */
export function deductModuleApplicationCountAction(params: any) {
  return request<any>({
    url: Api.DeductCount,
    method: 'post',
    data: params
  });
}

/**
 * 根据文件夹获取图片数据
 *
 * @param params
 */
export function getImageDataByTenantAction(params: any) {
  return request<any>({
    url: Api.SelectPicByTenant,
    method: 'get',
    params
  });
}

/**
 * 分步生成
 *
 * @param params
 */
export function stepGenerateAction(params: any) {
  return statusRequest<any>({
    url: Api.StepGenerate,
    method: 'post',
    data: params
  });
}

/**
 * 一键编写
 *
 * @param params
 */
export function processDocxAction(params: any) {
  return statusRequest<any>({
    url: Api.ProcessDocx,
    method: 'post',
    data: params
  });
}

/**
 * 状态查询
 *
 * @param params
 */
export function documentStatusAction(params: any) {
  return statusRequest<any>({
    url: Api.DocumentStatus,
    method: 'post',
    data: params
  });
}

/**
 * 内容建议
 *
 * @param params
 */
export function contentFillAction(params: any) {
  return statusRequest<any>({
    url: Api.ContentFill,
    method: 'post',
    data: params
  });
}

/**
 * 取消任务排队
 *
 * @param params
 */
export function cancelTaskGenerateAction(params: any) {
  return statusRequest<any>({
    url: Api.GenerateCancel,
    method: 'post',
    data: params
  });
}

/**
 * 会话内容生成
 *
 * @param params
 */
export function generateContent(params: any) {
  return chatRequest<any>({
    url: Api.AiChat,
    method: 'post',
    data: params
  });
}

/**
 * 查询是否有生成的标书
 */
export function getBidTipsAction() {
  return request<any>({
    url: Api.GetBidTips,
    method: 'get'
  });
}

/**
 * 敏感词校验
 *
 * @param params
 */
export function msgCheckAction(params: any) {
  return request<any>({
    url: Api.MsgCheck,
    method: 'post',
    data: params
  });
}
